Change in openvpn[master]: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
A message that is not in the archive (sent off-list or not yet received): gerrit.1742815876000.I1c2c050dd160746a0f8d9c234abe1e258bc8e48d@...2715...
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
to review the following change.
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
---
M src/openvpn/multi.c
M src/openvpn/options.c
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
4 files changed, 39 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/913/1
src/openvpn/multi.c +6 -0
@@ -2705,6 +2705,12 @@if (!multi->locked_original_username &&strcmp (multi->locked_username, options->override_username) !=0 ) { +/* Check if the username length is acceptable */ +if (!ssl_verify_username_length (session, options->override_username)) + { +return false; + } + multi->locked_original_username = multi->locked_username; multi->locked_username =strdup (options->override_username);
src/openvpn/options.c +2 -2
@@ -7875,10 +7875,10 @@else if (streq (p[0 ],"override-username" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_INSTANCE ); -if (strlen (p[1 ]) >TLS_USERNAME_LEN ) +if (strlen (p[1 ]) >USER_PASS_LEN ) {msg (msglevel,"override-username exceeds the maximum length of %d " -"characters" ,TLS_USERNAME_LEN ); +"characters" ,USER_PASS_LEN );/* disable the connection since ignoring the request to * set another username might cause serious problems */
src/openvpn/ssl_verify.c +17 -5
@@ -1568,6 +1568,21 @@ } } +bool +ssl_verify_username_length (struct tls_session *session,const char *username) +{ +if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) + &&strlen (username) >TLS_USERNAME_LEN ) + { +msg (D_TLS_ERRORS , +"TLS Auth Error: --username-as-common name specified and " +"username is longer than the maximum permitted Common Name " +"length of %d characters" ,TLS_USERNAME_LEN ); +return false; + } +return true; +} +/** * Main username/password verification entry point *
@@ -1689,15 +1704,12 @@ }/* check sizing of username if it will become our common name */ -if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) - &&strlen (up->username)>TLS_USERNAME_LEN ) +if (ssl_verify_username_length (session, up->username)) { -msg (D_TLS_ERRORS , -"TLS Auth Error: --username-as-common name specified and username is longer than the maximum permitted Common Name length of %d characters" , -TLS_USERNAME_LEN ); plugin_status =OPENVPN_PLUGIN_FUNC_ERROR ; script_status =OPENVPN_PLUGIN_FUNC_ERROR ; } +/* auth succeeded? */ bool plugin_ok = plugin_status ==OPENVPN_PLUGIN_FUNC_SUCCESS || plugin_status ==OPENVPN_PLUGIN_FUNC_DEFERRED ;
src/openvpn/ssl_verify.h +14 -0
@@ -192,6 +192,20 @@ struct tls_session *session); +/** +* Checks if the username length is valid to use. This checks when +* username-as-common-name is active if the username is shorter than +* the maximum TLS common name length (64). +* +* It will also display an error message if the name is too long +* +* @param session current TLS session +* @param username username to check +* @return true if name is under limit or username-as-common-name +* is not active +*/ +bool ssl_verify_username_length (struct tls_session *session, +const char *username);/** * Runs the --client-crresponse script if one is defined.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
to look at the new patch set (#2).
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Currently override-username is artificially restricted to the length of TLS common-name for the corner case of using username-as-common-name, which we explicitly do not recommend.
Do away with that limitation and only error out on longer usernames when username-as-common-name is actually in effect.
---
M src/openvpn/multi.c
M src/openvpn/options.c
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
4 files changed, 42 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/913/2
src/openvpn/multi.c +6 -0
@@ -2705,6 +2705,12 @@if (!multi->locked_original_username &&strcmp (multi->locked_username, options->override_username) !=0 ) { +/* Check if the username length is acceptable */ +if (!ssl_verify_username_length (session, options->override_username)) + { +return false; + } + multi->locked_original_username = multi->locked_username; multi->locked_username =strdup (options->override_username);
src/openvpn/options.c +2 -2
@@ -7875,10 +7875,10 @@else if (streq (p[0 ],"override-username" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_INSTANCE ); -if (strlen (p[1 ]) >TLS_USERNAME_LEN ) +if (strlen (p[1 ]) >USER_PASS_LEN ) {msg (msglevel,"override-username exceeds the maximum length of %d " -"characters" ,TLS_USERNAME_LEN ); +"characters" ,USER_PASS_LEN );/* disable the connection since ignoring the request to * set another username might cause serious problems */
src/openvpn/ssl_verify.c +20 -5
@@ -1568,6 +1568,24 @@ } } +bool +ssl_verify_username_length (struct tls_session *session,const char *username) +{ +if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) + &&strlen (username) >TLS_USERNAME_LEN ) + { +msg (D_TLS_ERRORS , +"TLS Auth Error: --username-as-common name specified and " +"username is longer than the maximum permitted Common Name " +"length of %d characters" ,TLS_USERNAME_LEN ); +return false; + } +else + { +return true; + } +} +/** * Main username/password verification entry point *
@@ -1689,15 +1707,12 @@ }/* check sizing of username if it will become our common name */ -if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) - &&strlen (up->username)>TLS_USERNAME_LEN ) +if (ssl_verify_username_length (session, up->username)) { -msg (D_TLS_ERRORS , -"TLS Auth Error: --username-as-common name specified and username is longer than the maximum permitted Common Name length of %d characters" , -TLS_USERNAME_LEN ); plugin_status =OPENVPN_PLUGIN_FUNC_ERROR ; script_status =OPENVPN_PLUGIN_FUNC_ERROR ; } +/* auth succeeded? */ bool plugin_ok = plugin_status ==OPENVPN_PLUGIN_FUNC_SUCCESS || plugin_status ==OPENVPN_PLUGIN_FUNC_DEFERRED ;
src/openvpn/ssl_verify.h +14 -0
@@ -192,6 +192,20 @@ struct tls_session *session); +/** +* Checks if the username length is valid to use. This checks when +* username-as-common-name is active if the username is shorter than +* the maximum TLS common name length (64). +* +* It will also display an error message if the name is too long +* +* @param session current TLS session +* @param username username to check +* @return true if name is under limit or username-as-common-name +* is not active +*/ +bool ssl_verify_username_length (struct tls_session *session, +const char *username);/** * Runs the --client-crresponse script if one is defined.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/913?usp=email )
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Patch Set 2: Code-Review-2
(1 comment)
File src/openvpn/ssl_verify.c:
http://gerrit.openvpn.net/c/openvpn/+/913/comment/471048b9_b3cd29b2 :
PS2, Line 1710: if (ssl_verify_username_length(session, up->username))
Missing "not"?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 24 Mar 2025 13:38:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/913?usp=email )
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/ssl_verify.c:
http://gerrit.openvpn.net/c/openvpn/+/913/comment/973c8450_1d433ea8 :
PS2, Line 1710: if (ssl_verify_username_length(session, up->username))
Quoted 1 line
Missing "not"?
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 24 Mar 2025 13:42:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
to look at the new patch set (#3).
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Currently override-username is artificially restricted to the length of TLS common-name (64) for the corner case of using username-as-common-name, which we explicitly do not recommend to use.
Do away with that limitation and only error out on longer usernames when username-as-common-name is actually in effect.
---
M src/openvpn/multi.c
M src/openvpn/options.c
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
4 files changed, 42 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/913/3
src/openvpn/multi.c +6 -0
@@ -2705,6 +2705,12 @@if (!multi->locked_original_username &&strcmp (multi->locked_username, options->override_username) !=0 ) { +/* Check if the username length is acceptable */ +if (!ssl_verify_username_length (session, options->override_username)) + { +return false; + } + multi->locked_original_username = multi->locked_username; multi->locked_username =strdup (options->override_username);
src/openvpn/options.c +2 -2
@@ -7875,10 +7875,10 @@else if (streq (p[0 ],"override-username" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_INSTANCE ); -if (strlen (p[1 ]) >TLS_USERNAME_LEN ) +if (strlen (p[1 ]) >USER_PASS_LEN ) {msg (msglevel,"override-username exceeds the maximum length of %d " -"characters" ,TLS_USERNAME_LEN ); +"characters" ,USER_PASS_LEN );/* disable the connection since ignoring the request to * set another username might cause serious problems */
src/openvpn/ssl_verify.c +20 -5
@@ -1568,6 +1568,24 @@ } } +bool +ssl_verify_username_length (struct tls_session *session,const char *username) +{ +if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) + &&strlen (username) >TLS_USERNAME_LEN ) + { +msg (D_TLS_ERRORS , +"TLS Auth Error: --username-as-common name specified and " +"username is longer than the maximum permitted Common Name " +"length of %d characters" ,TLS_USERNAME_LEN ); +return false; + } +else + { +return true; + } +} +/** * Main username/password verification entry point *
@@ -1689,15 +1707,12 @@ }/* check sizing of username if it will become our common name */ -if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) - &&strlen (up->username)>TLS_USERNAME_LEN ) +if (!ssl_verify_username_length (session, up->username)) { -msg (D_TLS_ERRORS , -"TLS Auth Error: --username-as-common name specified and username is longer than the maximum permitted Common Name length of %d characters" , -TLS_USERNAME_LEN ); plugin_status =OPENVPN_PLUGIN_FUNC_ERROR ; script_status =OPENVPN_PLUGIN_FUNC_ERROR ; } +/* auth succeeded? */ bool plugin_ok = plugin_status ==OPENVPN_PLUGIN_FUNC_SUCCESS || plugin_status ==OPENVPN_PLUGIN_FUNC_DEFERRED ;
src/openvpn/ssl_verify.h +14 -0
@@ -192,6 +192,20 @@ struct tls_session *session); +/** +* Checks if the username length is valid to use. This checks when +* username-as-common-name is active if the username is shorter than +* the maximum TLS common name length (64). +* +* It will also display an error message if the name is too long +* +* @param session current TLS session +* @param username username to check +* @return true if name is under limit or username-as-common-name +* is not active +*/ +bool ssl_verify_username_length (struct tls_session *session, +const char *username);/** * Runs the --client-crresponse script if one is defined.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/913?usp=email )
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Patch Set 3: -Code-Review
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Comment-Date: Mon, 24 Mar 2025 14:03:49 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/913?usp=email )
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Wed, 02 Apr 2025 13:45:28 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v3 1/1 Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
Currently override-username is artificially restricted to the length of TLS common-name (64) for the corner case of using username-as-common-name, which we explicitly do not recommend to use.
Do away with that limitation and only error out on longer usernames when username-as-common-name is actually in effect.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/913
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/multi.c +6 -0
@@ -2705,6 +2705,12 @@if (!multi->locked_original_username &&strcmp (multi->locked_username, options->override_username) !=0 ) { +/* Check if the username length is acceptable */ +if (!ssl_verify_username_length (session, options->override_username)) + { +return false; + } + multi->locked_original_username = multi->locked_username; multi->locked_username =strdup (options->override_username);
src/openvpn/options.c +2 -2
@@ -7875,10 +7875,10 @@else if (streq (p[0 ],"override-username" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_INSTANCE ); -if (strlen (p[1 ]) >TLS_USERNAME_LEN ) +if (strlen (p[1 ]) >USER_PASS_LEN ) {msg (msglevel,"override-username exceeds the maximum length of %d " -"characters" ,TLS_USERNAME_LEN ); +"characters" ,USER_PASS_LEN );/* disable the connection since ignoring the request to * set another username might cause serious problems */
src/openvpn/ssl_verify.c +20 -5
@@ -1568,6 +1568,24 @@ } } +bool +ssl_verify_username_length (struct tls_session *session,const char *username) +{ +if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) + &&strlen (username) >TLS_USERNAME_LEN ) + { +msg (D_TLS_ERRORS , +"TLS Auth Error: --username-as-common name specified and " +"username is longer than the maximum permitted Common Name " +"length of %d characters" ,TLS_USERNAME_LEN ); +return false; + } +else + { +return true; + } +} +/** * Main username/password verification entry point *
@@ -1689,15 +1707,12 @@ }/* check sizing of username if it will become our common name */ -if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) - &&strlen (up->username)>TLS_USERNAME_LEN ) +if (!ssl_verify_username_length (session, up->username)) { -msg (D_TLS_ERRORS , -"TLS Auth Error: --username-as-common name specified and username is longer than the maximum permitted Common Name length of %d characters" , -TLS_USERNAME_LEN ); plugin_status =OPENVPN_PLUGIN_FUNC_ERROR ; script_status =OPENVPN_PLUGIN_FUNC_ERROR ; } +/* auth succeeded? */ bool plugin_ok = plugin_status ==OPENVPN_PLUGIN_FUNC_SUCCESS || plugin_status ==OPENVPN_PLUGIN_FUNC_DEFERRED ;
src/openvpn/ssl_verify.h +14 -0
@@ -192,6 +192,20 @@ struct tls_session *session); +/** +* Checks if the username length is valid to use. This checks when +* username-as-common-name is active if the username is shorter than +* the maximum TLS common name length (64). +* +* It will also display an error message if the name is too long +* +* @param session current TLS session +* @param username username to check +* @return true if name is under limit or username-as-common-name +* is not active +*/ +bool ssl_verify_username_length (struct tls_session *session, +const char *username);/** * Runs the --client-crresponse script if one is defined.
[Openvpn-devel] [PATCH applied] Re: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
"Because it makes sense" :-) - haven't explicitly tested all the various corner cases, but the important bits are quite obvious from stare-at-code.
ssl_verify_username_length() looks "new" but is just refactored from existing in-function code for reuse.
Your patch has been applied to the master branch.
commit bb8f2e373cf5d6c4d4320694ddd14bb61d5756b3
Author: Arne Schwabe Date: Wed Apr 2 15:45:39 2025 +0200
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31323.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#4) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/913?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Currently override-username is artificially restricted to the length of TLS common-name (64) for the corner case of using username-as-common-name, which we explicitly do not recommend to use.
Do away with that limitation and only error out on longer usernames when username-as-common-name is actually in effect.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31323.html
---
M src/openvpn/multi.c
M src/openvpn/options.c
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
4 files changed, 42 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/913/4
src/openvpn/multi.c +6 -0
@@ -2705,6 +2705,12 @@if (!multi->locked_original_username &&strcmp (multi->locked_username, options->override_username) !=0 ) { +/* Check if the username length is acceptable */ +if (!ssl_verify_username_length (session, options->override_username)) + { +return false; + } + multi->locked_original_username = multi->locked_username; multi->locked_username =strdup (options->override_username);
src/openvpn/options.c +2 -2
@@ -7880,10 +7880,10 @@else if (streq (p[0 ],"override-username" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_INSTANCE ); -if (strlen (p[1 ]) >TLS_USERNAME_LEN ) +if (strlen (p[1 ]) >USER_PASS_LEN ) {msg (msglevel,"override-username exceeds the maximum length of %d " -"characters" ,TLS_USERNAME_LEN ); +"characters" ,USER_PASS_LEN );/* disable the connection since ignoring the request to * set another username might cause serious problems */
src/openvpn/ssl_verify.c +20 -5
@@ -1568,6 +1568,24 @@ } } +bool +ssl_verify_username_length (struct tls_session *session,const char *username) +{ +if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) + &&strlen (username) >TLS_USERNAME_LEN ) + { +msg (D_TLS_ERRORS , +"TLS Auth Error: --username-as-common name specified and " +"username is longer than the maximum permitted Common Name " +"length of %d characters" ,TLS_USERNAME_LEN ); +return false; + } +else + { +return true; + } +} +/** * Main username/password verification entry point *
@@ -1689,15 +1707,12 @@ }/* check sizing of username if it will become our common name */ -if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) - &&strlen (up->username)>TLS_USERNAME_LEN ) +if (!ssl_verify_username_length (session, up->username)) { -msg (D_TLS_ERRORS , -"TLS Auth Error: --username-as-common name specified and username is longer than the maximum permitted Common Name length of %d characters" , -TLS_USERNAME_LEN ); plugin_status =OPENVPN_PLUGIN_FUNC_ERROR ; script_status =OPENVPN_PLUGIN_FUNC_ERROR ; } +/* auth succeeded? */ bool plugin_ok = plugin_status ==OPENVPN_PLUGIN_FUNC_SUCCESS || plugin_status ==OPENVPN_PLUGIN_FUNC_DEFERRED ;
src/openvpn/ssl_verify.h +14 -0
@@ -192,6 +192,20 @@ struct tls_session *session); +/** +* Checks if the username length is valid to use. This checks when +* username-as-common-name is active if the username is shorter than +* the maximum TLS common name length (64). +* +* It will also display an error message if the name is too long +* +* @param session current TLS session +* @param username username to check +* @return true if name is under limit or username-as-common-name +* is not active +*/ +bool ssl_verify_username_length (struct tls_session *session, +const char *username);/** * Runs the --client-crresponse script if one is defined.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/913?usp=email )
Change subject: Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
......................................................................
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Currently override-username is artificially restricted to the length of TLS common-name (64) for the corner case of using username-as-common-name, which we explicitly do not recommend to use.
Do away with that limitation and only error out on longer usernames when username-as-common-name is actually in effect.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31323.html
---
M src/openvpn/multi.c
M src/openvpn/options.c
M src/openvpn/ssl_verify.c
M src/openvpn/ssl_verify.h
4 files changed, 42 insertions(+), 7 deletions(-)
src/openvpn/multi.c +6 -0
@@ -2705,6 +2705,12 @@if (!multi->locked_original_username &&strcmp (multi->locked_username, options->override_username) !=0 ) { +/* Check if the username length is acceptable */ +if (!ssl_verify_username_length (session, options->override_username)) + { +return false; + } + multi->locked_original_username = multi->locked_username; multi->locked_username =strdup (options->override_username);
src/openvpn/options.c +2 -2
@@ -7880,10 +7880,10 @@else if (streq (p[0 ],"override-username" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_INSTANCE ); -if (strlen (p[1 ]) >TLS_USERNAME_LEN ) +if (strlen (p[1 ]) >USER_PASS_LEN ) {msg (msglevel,"override-username exceeds the maximum length of %d " -"characters" ,TLS_USERNAME_LEN ); +"characters" ,USER_PASS_LEN );/* disable the connection since ignoring the request to * set another username might cause serious problems */
src/openvpn/ssl_verify.c +20 -5
@@ -1568,6 +1568,24 @@ } } +bool +ssl_verify_username_length (struct tls_session *session,const char *username) +{ +if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) + &&strlen (username) >TLS_USERNAME_LEN ) + { +msg (D_TLS_ERRORS , +"TLS Auth Error: --username-as-common name specified and " +"username is longer than the maximum permitted Common Name " +"length of %d characters" ,TLS_USERNAME_LEN ); +return false; + } +else + { +return true; + } +} +/** * Main username/password verification entry point *
@@ -1689,15 +1707,12 @@ }/* check sizing of username if it will become our common name */ -if ((session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) - &&strlen (up->username)>TLS_USERNAME_LEN ) +if (!ssl_verify_username_length (session, up->username)) { -msg (D_TLS_ERRORS , -"TLS Auth Error: --username-as-common name specified and username is longer than the maximum permitted Common Name length of %d characters" , -TLS_USERNAME_LEN ); plugin_status =OPENVPN_PLUGIN_FUNC_ERROR ; script_status =OPENVPN_PLUGIN_FUNC_ERROR ; } +/* auth succeeded? */ bool plugin_ok = plugin_status ==OPENVPN_PLUGIN_FUNC_SUCCESS || plugin_status ==OPENVPN_PLUGIN_FUNC_DEFERRED ;
src/openvpn/ssl_verify.h +14 -0
@@ -192,6 +192,20 @@ struct tls_session *session); +/** +* Checks if the username length is valid to use. This checks when +* username-as-common-name is active if the username is shorter than +* the maximum TLS common name length (64). +* +* It will also display an error message if the name is too long +* +* @param session current TLS session +* @param username username to check +* @return true if name is under limit or username-as-common-name +* is not active +*/ +bool ssl_verify_username_length (struct tls_session *session, +const char *username);/** * Runs the --client-crresponse script if one is defined.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/913?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Gerrit-Change-Number: 913
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged